package cn.controller;

import cn.pojo.HealthTaboo;
import cn.service.HealthTabooService;
import cn.utils.BaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
@CrossOrigin
@RestController
@RequestMapping("/taboo")
public class HealthTabooController {


    @Autowired
    private HealthTabooService taboo;

    @GetMapping("/select")
    public Map<String, Object> select(String vaccineName) {
        return taboo.selectTaboo(vaccineName);
    }

    @PostMapping("/update")
    public Map<String, Object> update(HealthTaboo taboo) {
        taboo.setTabooTime(BaseUtils.getTime(0, "yyyy-MM-dd HH:mm:ss"));
        if (taboo.getTabooEye() != null) {
            taboo.setTabooEye(taboo.getTabooEye() + 1);
        }
        System.out.println(taboo);
        return this.taboo.updateTaboo(taboo);
    }

    @PostMapping("/add")
    public Map<String, Object> save(HealthTaboo taboo) {
        return this.taboo.saveTaboo(taboo);
    }

}
